<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List" %>
<%@page import="java.util.Map" %>
<%@page import="java.util.Iterator" %>
<%@page import="java.math.BigDecimal" %>
<%@page import="java.text.DecimalFormat" %>
<% List<Map<String, Object>> carretLl = (List<Map<String, Object>>) request.getAttribute("llistatCarret");
if ( carretLl == null || carretLl.isEmpty()) {
%>
    <span class="noProd">No hi ha productes</span>
<% } else { %>
    <div>
        <span class="uni"></span>
        <span class="nomItem">Nom Producte</span>
        <span class="euro">Subtotal</span>
        <span class="euro">&euro;&frasl;u</span>
    </div>

   <%
   Iterator<Map<String, Object>> it2 = carretLl.iterator();
   Map<String, Object> dada;
    while(it2.hasNext()) {
        dada = it2.next();
        DecimalFormat formatter = new DecimalFormat("####0.00");
   %>
    <div>
        <span class="uni"><%=dada.get("quantitat") %></span>
        <span class="nomItem"><%=dada.get("nom") %></span>
        <span class="euro"><%=formatter.format(((BigDecimal)dada.get("preu")).floatValue()*((BigDecimal)dada.get("quantitat")).intValue()) %>&euro;</span>
        <span class="euro"><%=dada.get("preu") %>&euro;</span>
    </div>
    <%  } %>
    <div class="totalC">Total: <%=request.getAttribute("totalCarret") %></div>
<%  } %>
